//
//  LPOrangizeStreetTableViewCell.m
//  ShangHaiHuDongApp
//
//  Created by 刘应平 on 2017/8/21.
//  Copyright © 2017年 刘应平. All rights reserved.
//

#import "LPOrangizeStreetTableViewCell.h"

@interface LPOrangizeStreetTableViewCell ()
/**  label  */
@property (strong, nonatomic) UILabel  *label;

@end
@implementation LPOrangizeStreetTableViewCell

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}



- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        self.selectionStyle = UITableViewCellSelectionStyleNone;
        [self addSubview:self.label];
        self.label.sd_layout.topSpaceToView(self, 15 * [UIScreen zj_screenHScale])
        .leftSpaceToView(self, 15 * [UIScreen zj_screenWScale])
        .rightSpaceToView(self, 15 * [UIScreen zj_screenWScale])
        .heightIs(20 * [UIScreen zj_screenHScale]);
    }
    return self;
}
- (void)setModel:(LPOrangeStreetModel *)model{
    _model = model;
    self.label.text = model.DEPT_NAME;
   CGFloat height  = [CalculateLabelHeight CalculateLabelHeightWithString:@"中英" font:16 * [UIScreen zj_textFontScale] width:[UIScreen zj_screenWith] - 30 * [UIScreen zj_screenWScale]].height;
    NSInteger zheng = model.HEIGHT / height;
    CGFloat lableHeiht = 0.0;
    if (zheng > 2) {
        lableHeiht = height * 2 + 5 * [UIScreen zj_screenHScale];
    }else{
        lableHeiht = model.HEIGHT;
    }
    
    self.label.sd_layout.heightIs(lableHeiht + 1);
    [self.label updateLayout];
}

- (UILabel *)label{
    if (!_label) {
        _label = ({
            UILabel *label = [UILabel new];
            label.textAlignment = NSTextAlignmentLeft;
            label.textColor = [UIColor textBlackColor];
            label.backgroundColor = [UIColor clearColor];
            label.font = LYPFONT(16);
            label.numberOfLines = 2;
            label;
        });
    }
    return _label;
}

@end
